//
//  EducationLiveGloabl.m
//  EducationLive
//
//  Created by Apple on 2017/10/16.
//  Copyright © 2017年 ZhouHao. All rights reserved.
//

#import "EducationLiveGloabl.h"
#import "Define_Basic.h"

@implementation EducationLiveGloabl

GPL_M_SINGLETON(EducationLiveGloabl);

// 设置导航栏左右按钮
+ (void)setNavButton:(UIViewController *)vc imageName:(NSString *)imageName setTitle:(NSString *)title setTitleColor:(UIColor *)Titlecolor titleSize:(CGFloat)titleSize action:(SEL)action withFrame:(CGRect)Frame direction:(NSString *)direction
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = Frame;
    button.backgroundColor = [UIColor clearColor];
    if (title.length > 0) {
        [button setTitle:title forState:UIControlStateNormal];
        [button setTitleColor:Titlecolor forState:UIControlStateNormal];
        button.titleLabel.font = Text_Font(titleSize);
    }
    if(imageName.length > 0){
        [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    }
    [button addTarget:vc action:action forControlEvents:UIControlEventTouchUpInside];
    if ([direction isEqualToString:@"left"]) {
        //按钮内容靠左对齐
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    }else if([direction isEqualToString:@"right"]){
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    }
    /**
     *  添加到Item中
     */
    UIBarButtonItem *ButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    if ([direction isEqualToString:@"left"]) {
        vc.navigationItem.leftBarButtonItem = ButtonItem;
    }else if([direction isEqualToString:@"right"]){
        vc.navigationItem.rightBarButtonItem = ButtonItem;
    }
}

@end
